﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;

namespace PhamMemQuanLyHocSinh
{
    public partial class frmQLSV : Form
    {
        DataTable dtDSSV;
        DataView dvDSSV;
        public frmQLSV()
        {
            InitializeComponent();
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            frmTTChiTiet frmTTCT = new frmTTChiTiet();
            frmTTCT.Show();
        }

        private void frmQLHS_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'qLSVDataSet.SINHVIEN' table. You can move, or remove it, as needed.
            //this.sINHVIENTableAdapter.Fill(this.qLSVDataSet.SINHVIEN);
            // TODO: This line of code loads data into the 'qLSVDataSet.LOP' table. You can move, or remove it, as needed.
            this.lOPTableAdapter.Fill(this.qLSVDataSet.LOP);
            //Load du lieu cho gridview DSHS
            LoaddgvDSHS();
            //Load du lieu cho combobox LopHoc
            
            
        }
        private void DoiTendgv()
        {
            dgvDSHS.Columns["MASV"].HeaderText = "Mã Sinh Viên";
            dgvDSHS.Columns["HOTEN"].HeaderText = "Họ Tên";
            dgvDSHS.Columns["NGAYSINH"].HeaderText = "Ngày Sinh";
            dgvDSHS.Columns["GIOITINH"].HeaderText = "Giới Tính";
            dgvDSHS.Columns["DIACHI"].HeaderText = "Địa Chỉ";
            dgvDSHS.Columns["DANTOC"].HeaderText = "Dân Tộc";
            dgvDSHS.Columns["Email"].HeaderText = "Email";
            dgvDSHS.Columns["MALOP"].HeaderText = "Mã Lớp";
            dgvDSHS.Columns["TENCHA"].HeaderText = "Họ Tên Cha";
            dgvDSHS.Columns["NAMSINHCHA"].HeaderText = "Năm Sinh Cha";
            dgvDSHS.Columns["DIACHICHA"].HeaderText = "Địa Chỉ Cha";
            dgvDSHS.Columns["SDTCHA"].HeaderText = "Điện Toại Cha";
            dgvDSHS.Columns["NGHECHA"].HeaderText = "Nghề Nghiệp";
            dgvDSHS.Columns["TENME"].HeaderText = "Họ Tên Mẹ";
            dgvDSHS.Columns["NAMSINHME"].HeaderText = "Năm Sinh Mẹ";
            dgvDSHS.Columns["DIACHIME"].HeaderText = "Địa Chỉ Mẹ";
            dgvDSHS.Columns["SDTME"].HeaderText = "Điện Toại Mẹ";
            dgvDSHS.Columns["NGHEME"].HeaderText = "Nghề Nghiệp";
            dgvDSHS.Columns["HINHANH"].HeaderText = "Hình Ảnh";
            dgvDSHS.Columns["TRANGTHAI"].HeaderText = "Trạng Thái";
        }
        private void LoaddgvDSHS()
        {
            dtDSSV = HocSinh_BLL.LoadDSHS();
            dgvDSHS.DataSource = dvDSSV;
            //DoiTendgv();     
        
        }
     
        private void cmbLopHoc_SelectedIndexChanged(object sender, EventArgs e)
        {
            dvDSSV = new DataView(dtDSSV);
            dvDSSV.RowFilter = string.Format("malop like '%{0}%'", cmbLopHoc.SelectedValue.ToString());
            dgvDSHS.DataSource = dvDSSV;
            //DoiTendgv();
        }
   }   
   
}
